
#ifndef UTIL_H_
#define UTIL_H_

#define     boolean     char
#define     true     1
#define     false    0

#define     min(a, b)    ((a) < (b)? (a) : (b))
#define     max(a, b)    ((a) < (b)? (b) : (a))

typedef struct _position {
    short x, y;
} Pos;


typedef enum {
    dir_up = (1 << 0),
    dir_down = (1 << 1),
    dir_left = (1 << 2),
    dir_right = (1 << 3),
    dir_upleft = (1 << 4),
    dir_upright = (1 << 5),
    dir_downleft = (1 << 6),
    dir_downright = (1 << 7)
} Dir;

typedef struct _rect {
    char startX, endX, startY, endY;
} ClipRect;

void GetClipRect(ClipRect *r, Pos oldP, Pos newP);

#endif
